package com.wx.handler.security;

import com.wx.common.WrapMapper;
import com.wx.enums.CommonExceptionEnum;
import com.wx.utils.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>Title:      CustomerLoginAuthEntryPoint. </p>
 * <p>Description 权限认证异常处理器 </p>
 * <p>Copyright: Copyright (c) 2016</p>
 * <p>Company:    医百科技有限公司 </p>
 *
 * @author         <a href="xinglinglove1029@163.com"/>杨文生</a>
 * @since      2019/8/12 21:32
 */
@Component("customerLoginAuthEntryPoint")
@Slf4j
public class CustomerLoginAuthEntryPoint implements AuthenticationEntryPoint {


    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse response, AuthenticationException authException){
        ResponseUtil.write(response, WrapMapper.error(CommonExceptionEnum.GL401.getCode(), CommonExceptionEnum.GL401.getMsg()));
    }

}
